package com.qifenqian.turbot.module.adapter.restaurant

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.qifenqian.turbot.R
import com.qifenqian.turbot.module.entity.response.StaffEntity
import kotlinx.android.synthetic.main.item_staff_manage.view.*

/**
 * @author H
 * @createTime 2018/12/20 15:58
 * @description
 * @see
 * @since
 */
class StaffManageAdapter(data: MutableList<StaffEntity>?) : BaseQuickAdapter<StaffEntity, BaseViewHolder>(R.layout.item_staff_manage, data) {

    override fun convert(helper: BaseViewHolder, item: StaffEntity) {
        val view = helper.itemView
        view.tv_item_staff_manage_name.text= item.userName
        view.tv_item_staff_manage_phone.text= item.userCode
        view.btn_item_staff_manage_edit.setOnClickListener {
            if (onItemChildClickListener != null) {
                onItemChildClickListener!!.onEditClick(helper.layoutPosition)
            }
        }
        view.btn_item_staff_manage_delete.setOnClickListener {
            if (onItemChildClickListener != null) {
                onItemChildClickListener!!.onDeleteClick(helper.layoutPosition)
            }
        }

    }

    private var onItemChildClickListener: OnItemChildClickListener? = null

    fun setOnChildClickListener(listener: OnItemChildClickListener) {
        onItemChildClickListener = listener
    }

    interface OnItemChildClickListener {
        fun onEditClick(position: Int)
        fun onDeleteClick(position: Int)
    }
}
